package com.cai.servlet.user;

import com.cai.dao.UserDao;
import com.cai.dao.impl.UserDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author RuoLi
 * 用户修改密码
 */
@WebServlet(name = "ServletUserUpdatePassword", value = "/User/UserUpdatePassword")
public class ServletUserUpdatePassword extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        UserDao userDao=new UserDaoImpl();
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        String userAccount = req.getParameter("userAccount");
        String userMail=req.getParameter("userEmail");
        String password = req.getParameter("password");
        int data= userDao.updateUserPassword(userAccount,userMail,password);
        if (data!=0){
            //修改成功 发送邮箱信息
            resp.getWriter().write(String.valueOf(data));
        }
    }
}
